//未完 部分功能


package com.practice;

import java.util.Random;
import java.util.Scanner;

public class DoubleColor {
    public static void main(String[] args) {
        //系统生成双色球号码
        int[] redBall = new int[6];
        int blueBall = Occur(redBall);
        //展示中奖的双色球号码
        System.out.print("中奖的红球号码为： ");
        for (int i = 0; i < 6; i++) {
            System.out.print(redBall[i] + " ");
        }
        System.out.println(" ");
        System.out.print("中奖的蓝球号码为： ");
        System.out.println(blueBall);
        //购买的双色球
        int[] your_redBall = new int[redBall.length];
        int your_blueBall = Buy(your_redBall);
        //展示购买的双色球号码
        Show(your_redBall, your_blueBall);
        //判断中奖
        Judge(redBall,your_redBall,blueBall,your_blueBall);
    }

    //系统生成双色球号码
    public static int Occur(int[] redBall) {
        Random r = new Random();
        int blueBall = r.nextInt(16) + 1;
        for (int i = 0; i < redBall.length; i++) {
            redBall[i] = r.nextInt(33) + 1;
        }
        return blueBall;
    }

    //购买的双色球
    public static int Buy(int[] your_redBall) {
        System.out.println("请输入你要买的红球号码：");
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < your_redBall.length; ) {
            int input = sc.nextInt();
            if (input >= 1 && input <= 33) {//问题发现  重复输入问题
                your_redBall[i] = input;
                i++;
            } else System.out.println("输入错误，请继续输入：");
        }
        System.out.println("请输入你要买的蓝球号码：");
        boolean flag = false;
        int your_blueBall = 0;
        while (!flag) {
            your_blueBall = sc.nextInt();
            if (your_blueBall >= 1 && your_blueBall <= 16) {
                flag = true;
                return your_blueBall;
            } else System.out.println("输入错误，请继续输入：");
        }
        return your_blueBall;
    }

    //展示购买的双色球号码
    public static void Show(int[] your_redBall, int your_blueBall) {
        System.out.println("这是您选择的红球号码：");
        for (int i = 0; i < your_redBall.length; i++) {
            System.out.print(your_redBall[i] + " ");
        }
        System.out.println(" ");
        System.out.println("这是您选择的蓝球号码：");
        System.out.println(your_blueBall);
    }

    //判断中奖
    public static void Judge(int[] redBall,int[] your_redBall,int blueBall,int your_blueBall) {
        int redPrize = 0;
        int bluePrize = 0;
        for (int i = 0; i < redBall.length; i++) {
            for (int j = 0; j < your_redBall.length; j++) {
                if (redBall[i] == your_redBall[j]) {
                    redPrize++;
                    break;
                }
            }
        }
        if (blueBall == your_blueBall) {
            System.out.println("蓝色对");
            bluePrize++;
        } else
            System.out.println("蓝色不对");
        System.out.println(redPrize);
    }
}
